home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 43
/
Mac Magazin and MacEasy Magazine CD - Issue 43.iso
/
Software
/
Mobiles Büro
/
Newton
/
Newton Entwickler
/
DIL 2.0 Mac OS ƒ
/
Headers
/
DIL.h
< prev
next >
Wrap
Text File
|
1997-09-19
|
4KB
|
139 lines
/*
File: DIL.h, v2.0a2
Contains: Public interface to the Desktop Integration Library
Copyright: Apple Computer, Inc. 1997, all rights reserved.
*/
#ifndef __DIL_H
#define __DIL_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32) && defined(macintosh)
#error Please define only one of _WIN32 or macintosh
#endif
#if !defined(_WIN32) && !defined(macintosh)
#error Please define either _WIN32 or macintosh
#endif
#ifdef _WIN32
#define DIL_HasByteSwapping 1
#define DECLSPEC_EXPORT __declspec(dllexport)
#define DECLSPEC_IMPORT __declspec(dllimport)
#if defined(BUILDING_DIL)
#define DILAPI DECLSPEC_EXPORT
#else
#define DILAPI DECLSPEC_IMPORT
#endif
#else
#define DILAPI
#endif
#define DECLARE_DIL_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
typedef unsigned short DIL_WideChar;
typedef long DIL_Error;
#define kDIL_NoError (0)
#define kDIL_ErrorBase (-98000)
/* --- General DIL errors --- */
#define kDIL_OutOfMemory (kDIL_ErrorBase - 1)
#define kDIL_InvalidParameter (kDIL_ErrorBase - 2)
#define kDIL_InternalError (kDIL_ErrorBase - 3)
#define kDIL_ErrorReadingFromPipe (kDIL_ErrorBase - 4)
#define kDIL_ErrorWritingToPipe (kDIL_ErrorBase - 5)
#define kDIL_InvalidHandle (kDIL_ErrorBase - 6)
/* --- Base error numbers --- */
#define kCD_ErrorBase (kDIL_ErrorBase - 200)
#define kFD_ErrorBase (kDIL_ErrorBase - 400)
#define kPD_ErrorBase (kDIL_ErrorBase - 600)
/*
** Procedures for providing data to or receiving data from the DILs. DIL_WriteProc
** should take the profferred amount of data and write it somewhere (to a file or
** memory buffer, perhaps). DIL_ReadProc should cough up the requested number of
** of bytes. If either function succeeds, it returns kDIL_NoError. If not, it
** returns some non-zero error number.
*/
typedef DIL_Error (*DIL_WriteProc)(const void* buf, long amt, void* userData);
typedef DIL_Error (*DIL_ReadProc)(void* buf, long amt, void* userData);
#ifdef __cplusplus
} /* extern "C" */
#endif
/*
** --------------------------------------------------------------------------------
** Byte swapping
** --------------------------------------------------------------------------------
*/
/* Watch out for these macros...they can silently turn your values into different types... */
#define DIL_BYTE_SWAP_8(n) (n)
#define DIL_BYTE_SWAP_16(n) (((n >> 8) & 0x000000FF) | ((n << 8) & 0x0000FF00))
#define DIL_BYTE_SWAP_32(n) (((n << 24) & 0xFF000000) | ((n << 8) & 0x00FF0000) | ((n >> 8) & 0x0000FF00) | ((n >> 24) & 0x000000FF))
/*
** The following macros are for code with static data that
** assumes ordering different from native ordering
*/
#ifdef DIL_HasByteSwapping
#define DIL_CANONICAL_8(n) DIL_BYTE_SWAP_8(n)
#define DIL_CANONICAL_16(n) DIL_BYTE_SWAP_16(n)
#define DIL_CANONICAL_32(n) DIL_BYTE_SWAP_32(n)
#else
#define DIL_CANONICAL_8(n) (n)
#define DIL_CANONICAL_16(n) (n)
#define DIL_CANONICAL_32(n) (n)
#endif
#ifdef __cplusplus
inline signed char DIL_ByteSwap(signed char n) { return (signed char) DIL_BYTE_SWAP_8(n); }
inline char DIL_ByteSwap(char n) { return (char) DIL_BYTE_SWAP_8(n); }
inline unsigned char DIL_ByteSwap(unsigned char n) { return (unsigned char) DIL_BYTE_SWAP_8(n); }
inline short DIL_ByteSwap(short n) { return (short) DIL_BYTE_SWAP_16(n); }
inline unsigned short DIL_ByteSwap(unsigned short n) { return (unsigned short) DIL_BYTE_SWAP_16(n); }
inline long DIL_ByteSwap(long n) { return (long) DIL_BYTE_SWAP_32(n); }
inline unsigned long DIL_ByteSwap(unsigned long n) { return (unsigned long) DIL_BYTE_SWAP_32(n); }
inline signed char DIL_Canonical(signed char n) { return (signed char) DIL_CANONICAL_8(n); }
inline char DIL_Canonical(char n) { return (char) DIL_CANONICAL_8(n); }
inline unsigned char DIL_Canonical(unsigned char n) { return (unsigned char) DIL_CANONICAL_8(n); }
inline short DIL_Canonical(short n) { return (short) DIL_CANONICAL_16(n); }
inline unsigned short DIL_Canonical(unsigned short n) { return (unsigned short) DIL_CANONICAL_16(n); }
inline long DIL_Canonical(long n) { return (long) DIL_CANONICAL_32(n); }
inline unsigned long DIL_Canonical(unsigned long n) { return (unsigned long) DIL_CANONICAL_32(n); }
#endif
#endif /* __DIL_H */